from flask import Flask
from models.model import db
from apps.user import user_bp
from apps.news import news_bp
from flask_cors import CORS


def create_app(config):
    flask_app = Flask(__name__)

    # 加载配置文件
    flask_app.config.from_object(config)

    # 初始化db
    db.init_app(flask_app)

    # 跨域
    cors = CORS(flask_app)

    # 注册蓝图
    flask_app.register_blueprint(user_bp)
    flask_app.register_blueprint(news_bp)

    return flask_app
